import axios from 'axios'
import { ElMessage } from 'element-plus'

const service = axios.create({
    baseURL: 'http://127.0.0.1',
    timeout: 5000
})
// 请求拦截器
service.interceptors.request.use((config) => {
    // 携带token
    if (config.url != ('/login' || '/register')) {
        config.headers.Authorization = window.localStorage.getItem('token')
    }
    console.log(config)
    return config
})
// 响应拦截器
service.interceptors.response.use((response) => {
    const res = response.data
    console.log(res)
    return res
})
export default service